import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/Index'
import Login from '@/views/login/Index'
import Home from "@/views/home/Home";

const Product = () => import('@/views/product/Index')
const ProductList = () => import('@/views/product/list/Index')
const ProductCategory = () => import('@/views/product/category/Index')

const Order = () => import('@/views/order/Index')
const OrderList = () => import('@/views/order/list/Index')
const OrderCollect = () => import('@/views/order/collect/Index')

const Advert = () => import('@/views/advert/Index')
const AdvertList = () => import('@/views/advert/list/Index')

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        component: Layout,
        children: [
            {
                path: '/',
                name: 'home',
                component: Home
            },
            {
                path: '/product',//产品
                name: 'product',
                component: Product,
                children: [
                    {
                        path: 'list', // 访问路径 /product/list
                        name: 'productList',
                        component: ProductList
                    },
                    {
                        path: 'category',
                        name: 'productCategory',
                        component: ProductCategory
                    }
                ]
            },
            {
                path: '/order',//订单
                name: 'order',
                component: Order,
                children: [
                    {
                        path: 'list',
                        name: 'orderList',
                        component: OrderList
                    },
                    {
                        path: 'collect',
                        name: 'orderCollect',
                        component: OrderCollect
                    }
                ]
            },
            {
                path: '/advert',// 广告
                name: 'advert',
                component: Advert,
                children: [
                    {
                        path: 'list',
                        name: 'advertList',
                        component: AdvertList
                    }
                ]
            }
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: Login
    }

]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
